<%--
  Created by IntelliJ IDEA.
  User: Alta Y
  Date: 2019/10/3
  Time: 17:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
                <span class="layui-breadcrumb">
                    <a href="">首页</a>
                    <a href="">采购申请管理</a>
                    <a>
                        <cite>创建采购需求</cite></a>
                </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!-- <div class="layui-card-header">填写采购需求</div> -->
                <!-- 表单 -->
                <form class="layui-form" id="purchase">
                    <div class="layui-form-item">
                        <div class="layui-card-body ">
                            <fieldset class="layui-elem-field">
                                <legend>采购信息</legend>
                                <div class="layui-field-box">

                                    <div class="layui-row">
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">申请人</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <input type="text" name="create_user" autocomplete="off"
                                                           class="layui-input" value="${user.username}" readonly="readonly">
                                                </div>
                                            </div>
                                        </div>
                                        <c:set var="now" value="<%=new java.util.Date()%>" />
                                        <input type="hidden" name="write_date" value="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd HH:mm:ss"/>">

                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">申请单位</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <input type="text" name="" autocomplete="off"
                                                           class="layui-input" value="${user.dept.deptName}" readonly>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">单据编号</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <c:set var="now" value="<%=new java.util.Date()%>" />
                                                    <input type="text" name="bill_number" autocomplete="off"
                                                           class="layui-input" value="中能热电 - <fmt:formatDate value="${now}" pattern="yyyyMMdd - HHmmss"/>" readonly="readonly">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">报价截止时间</label>
                                                <div class="layui-input-inline " style="width: 200px;">
                                                    <input type="text" class="layui-input" id="test1" name="jh_time_end"
                                                           lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">交货时间</label>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input class="layui-input" autocomplete="off" placeholder="开始日"
                                                           name="jh_time" id="start" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid">-</div>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input class="layui-input" autocomplete="off" placeholder="截止日"
                                                           name="jh_time2" id="end"lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">签发人</label>
                                                <div class="layui-input-inline" style="width:200px;">
                                                    <input type="text" name="sign_name" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-row">
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">煤种</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <select name="coal_type" lay-verify="required">
                                                        <option value="1">烟煤</option>
                                                        <option value="2">无烟煤</option>
                                                        <option value="3">褐煤</option>
                                                        <option value="4">贫瘦煤</option>
                                                        <option value="5">其他</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">煤样</label>
                                                <div class="layui-input-inline" style="width: 200px;">
                                                    <select name="coal_class" lay-verify="required">
                                                        <option value="1">原煤</option>
                                                        <option value="2">混煤</option>
                                                        <option value="3">中煤</option>
                                                        <option value="4">煤泥</option>
                                                        <option value="5">其他</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">采购数量</label>
                                                <div class="layui-input-inline" style="width: 158px;">
                                                    <input type="number" name="qty" min="1" autocomplete="off" lay-verify="required"
                                                           class="layui-input">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(万吨)</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">交货地点</label>
                                                <div class="layui-input-inline" style="width:200px;">
                                                    <input type="text" name="delivery_mode" autocomplete="off" lay-verify="required"
                                                           class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">结算方式</label>
                                            <div class="layui-input-inline" style="width: 200px;">
                                                <select name="account_mode" lay-verify="required">
                                                    <option value="1">一票结算</option>
                                                    <option value="2">二票结算</option>
                                                    <option value="3">铁路大票</option>
                                                    <option value="4">煤款税票</option>
                                                    <option vaule="5">其他</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">验收方式</label>
                                            <div class="layui-input-inline" style="width: 200px;">
                                                <select name="check_mode" lay-verify="required">
                                                    <option value="1">到厂验收</option>
                                                    <option value="2">到厂第三方验收</option>
                                                    <option value="3">港口验收</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>


                                    <div class="layui-row">

                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">运输方式</label>
                                            <div class="layui-input-inline" style="width: 200px;">
                                                <select name="transport_mode" lay-verify="required">
                                                    <option value="1">火车</option>
                                                    <option value="2">汽车</option>
                                                    <option value="3">船运</option>
                                                    <option value="4">其他</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">最高限价</label>
                                                <div class="layui-input-inline" style="width: 128px;">
                                                    <input type="number" name="max_limit_price" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">（元/卡.吨）</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">最低限价</label>
                                                <div class="layui-input-inline" style="width: 128px;">
                                                    <input type="number" name="min_limit_price" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">（元/卡.吨）</div>
                                            </div>
                                        </div>


                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline" style="margin-bottom: 14px;">
                                                <label class="layui-form-label">限价说明</label>
                                                <div class="layui-input-inline" style="width: 1006px;">
                                                        <textarea name="max_remark" placeholder="请输入内容" class="layui-textarea"
                                                                  style="min-height: 50px;" lay-verify="required"></textarea>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline" style="margin-bottom: 14px;">
                                                <label class="layui-form-label">结算付款方式</label>
                                                <div class="layui-input-inline" style="width: 1006px;">
                                                        <textarea name="pay_mode" placeholder="请输入内容" class="layui-textarea"
                                                                  style="min-height: 50px;" lay-verify="required"></textarea>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 84px;padding-left: 11px;">报价保证金缴纳</label>
                                                <div class="layui-input-inline"
                                                     style="width: 300px;position: relative;">
                                                    <input type="radio" name="is_quotebond" value="1" title="不要求"
                                                           lay-filter="quo" checked>
                                                    <input type="radio" name="is_quotebond" value="0" title="要求"
                                                           lay-filter="quo">
                                                    <!-- <div class="layui-input-inline" style="width: 128px;"> -->
                                                    <div id="select_yaoq"
                                                         style="margin-left: -10px;display: none;position: absolute; ">
                                                        <input id="select_in1" type="number" min="0"
                                                               style="width: 50px; display: inline-block;" name="quotebond_number"
                                                               autocomplete="off" class="layui-input">
                                                        <!-- </div> -->
                                                        <div class="layui-form-mid layui-word-aux"
                                                             style="display: inline-block; float: none;">（元/卡.吨）
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 84px;padding-left: 11px;">履约保证金缴纳</label>
                                                <div class="layui-input-inline"
                                                     style="width: 300px; position: relative;">
                                                    <input type="radio" name="is_performbond" value="1"
                                                           title="不要求" lay-filter="per" checked>
                                                    <input  type="radio" name="is_performbond" value="0" title="要求"
                                                            lay-filter="per">
                                                    <!-- <div class="layui-input-inline" style="width: 128px;"> -->
                                                    <div id="select_per"
                                                         style="margin-left: -10px;display: none; position: absolute; ">
                                                        <input id="select_in2" type="number" min="0"
                                                               style="width: 50px; display: inline-block;" name="performbond_number"
                                                               autocomplete="off" class="layui-input">
                                                        <!-- </div> -->
                                                        <div class="layui-form-mid layui-word-aux"
                                                             style="display: inline-block; float: none;">
                                                            （元/卡.吨）
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset class="layui-elem-field">
                                <legend>煤质要求</legend>
                                <div class="layui-field-box">
                                    <fieldset class="layui-elem-field layui-field-title">
                                        <legend style="font-size: 16px;">收到基基准</legend>
                                    </fieldset>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">收到基低位发热量Qnet,ar≥</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_1" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(KCal/kg)</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">收到基全硫St,ar≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_4" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 180px;">全水分M≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_2" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">收到基灰分Aar≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_5" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">收到基挥发分Var</label>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="type_3" id="sdj_1" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid">至</div>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="type_3_2" id="sdj_2" lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <fieldset class="layui-elem-field layui-field-title">
                                        <legend style="font-size: 16px;">空气干燥基基准</legend>
                                    </fieldset>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">空干基水分Mad≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="kgj_1" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">空干基全硫St,ad≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="kgj_2" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">空干基挥发分Vad</label>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="kgj_3" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid">至</div>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="kgj_4" lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <fieldset class="layui-elem-field layui-field-title">
                                        <legend style="font-size: 16px;">干基基准</legend>
                                    </fieldset>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">干基高位发热量Qgr,d≥</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_9" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(KCal/kg)</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">干基全硫St,d≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_10" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">干燥无灰基挥发分</label>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="type_11" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid">至</div>
                                                <div class="layui-input-inline" style="width: 87px;">
                                                    <input type="number" class="layui-input" autocomplete="off"
                                                           name="type_12" lay-verify="required">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <fieldset class="layui-elem-field layui-field-title">
                                        <legend style="font-size: 16px;">其它</legend>
                                    </fieldset>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">粒度(mm)≤</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_8" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(KCal/kg)</div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md6">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">灰熔点ST(℃)≥</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_6" min="1" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(%)</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md5">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"
                                                       style="width: 180px;">哈式可磨系数(HGI)≥：</label>
                                                <div class="layui-input-inline" style="width: 206px;">
                                                    <input type="number" name="type_7" autocomplete="off"
                                                           class="layui-input" lay-verify="required">
                                                </div>
                                                <div class="layui-form-mid layui-word-aux">(KCal/kg)</div>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 180px;">备注</label>
                                                <div class="layui-input-inline" style="width: 706px;">
                                                                <textarea name="remark" placeholder="请输入内容" class="layui-textarea"
                                                                          style="min-height: 100px;" lay-verify="required"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                        <div class="layui-row">
                            <div class="pro_form_div" style="margin: 0 auto;width: 200px;padding-bottom: 40px;">
                                <button class="layui-btn" lay-filter="commit" lay-submit="">提交</button>
                                <button class="layui-btn" lay-filter="save" lay-submit="">保存</button>
                                <a href="/procurementList" class="layui-btn layui-btn-normal">返回</a>
                            </div>
                        </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>

<script>
    var div = document.getElementById("select_yaoq");
    var div2 = document.getElementById("select_per");
    var inp1 = document.getElementById("select_in1");
    var inp2 = document.getElementById("select_in2");
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form,
            layer = layui.layer;
        $ = layui.jquery;

        // 单选框点击事件
        form.on("radio(quo)", function (data) {
            var sex = data.value;
            if (this.value == '0') {
                div.style.display = "inline-block";
                inp1.setAttribute("lay-verify","required");

            } else {
                div.style.display = "none";
                inp1.setAttribute("lay-verify","");


            }
        });
        form.on("radio(per)", function (data) {
            var sex = data.value;
            if (this.value == '0') {
                div2.style.display = "inline-block";
                console.log(div2.firstChild);
                inp2.setAttribute("lay-verify","required");

            } else {
                div2.style.display = "none";
                inp2.setAttribute("lay-verify","");


            }
        });

        laydate.render({
            elem: '#test1'
            ,type: 'datetime'
            ,calendar: true
            ,min: 0

        });
        laydate.render({
            elem: '#start'
            ,calendar: true
            ,min: 0
        });
        laydate.render({
            elem: '#end'
            ,calendar: true
            ,min: 1
        });

        //监听提交
        form.on('submit(commit)',
            function (data) {

            //校验交货时间
            var jh_time = data.field.jh_time;
            var jh_time2 = data.field.jh_time2;
            var date1 = new Date(jh_time.replace(/-/g,"\/"));
            var date2 = new Date(jh_time2.replace(/-/g,"\/"));
                if(date1 >= date2){
                    layer.msg('交货时间范围出错', {icon: 7, time: 1000});
                    return false;
                }


            //校验最高限价和最低限价
            var max_limit_price = data.field.max_limit_price;
            var min_limit_price = data.field.min_limit_price;
                if(max_limit_price < min_limit_price){
                    layer.msg('最高限价不能小于最低限价', {icon: 7, time: 1000});
                    return false;
                }

            //校验收到基挥发分
            var type_3 = data.field.type_3;
            var type_3_2 = data.field.type_3_2;
                if(type_3 > type_3_2){
                    layer.msg('收到基挥发分Var填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

            //校验空气基挥发分
            var kgj_3 = data.field.kgj_3;
            var kgj_4 = data.field.kgj_4;
                if(kgj_4 < kgj_3){
                    layer.msg('空气基挥发分Var填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

            //校验干燥无灰基挥发分
            var type_11 = data.field.type_11;
            var type_12 = data.field.type_12;
                if(type_11 > type_12){
                    layer.msg('干燥无灰基挥发分填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

                $.ajax({
                    type:"post",
                    url:"/commit",
                    dataType:"json",
                    data: $('#purchase').serialize(),
                    success:function (data) {
                         if (data > 0){
                             layer.alert("提交成功，请等待审核", {
                                 icon: 6,
                                 time: 1000
                             });
                         }
                        window.setTimeout("window.location='/procurementList'",2000);
                    }
                });
                return false;
            });
        form.on('submit(save)',
            function (data) {

                //校验交货时间
                var jh_time = data.field.jh_time;
                var jh_time2 = data.field.jh_time2;
                var date1 = new Date(jh_time.replace(/-/g,"\/"));
                var date2 = new Date(jh_time2.replace(/-/g,"\/"));
                if(date1 >= date2){
                    layer.msg('交货时间范围出错', {icon: 7, time: 1000});
                    return false;
                }


                //校验最高限价和最低限价
                var max_limit_price = data.field.max_limit_price;
                var min_limit_price = data.field.min_limit_price;
                if(max_limit_price < min_limit_price){
                    layer.msg('最高限价不能小于最低限价', {icon: 7, time: 1000});
                    return false;
                }

                //校验收到基挥发分
                var type_3 = data.field.type_3;
                var type_3_2 = data.field.type_3_2;
                if(type_3 > type_3_2){
                    layer.msg('收到基挥发分Var填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

                //校验空气基挥发分
                var kgj_3 = data.field.kgj_3;
                var kgj_4 = data.field.kgj_4;
                if(kgj_4 < kgj_3){
                    layer.msg('空气基挥发分Var填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

                //校验干燥无灰基挥发分
                var type_11 = data.field.type_11;
                var type_12 = data.field.type_12;
                if(type_11 > type_12){
                    layer.msg('干燥无灰基挥发分填写范围错误', {icon: 7, time: 1000});
                    return false;
                }

                $.ajax({
                    type:"post",
                    url:"/savePurchase",
                    dataType:"json",
                    data: $('#purchase').serialize(),
                    success:function (data) {
                        if (data > 0){
                            layer.alert("保存成功，请等待提交", {
                                icon: 6,
                                time: 1000

                            });
                        }
                        window.setTimeout("window.location='/procurementList'",2000);
                    }
                });
                return false;
            });
    });
</script>
</body>

</html>
